#include "Assign.h"
#include "IVisitor.h"

Assign::Assign(const ExprTypeList& targets, const exprTypePtr& value, int nodeId):
    stmtType(nodeId),
    _targets(targets),
    _value(value)
{
}
    
Assign::~Assign()
{
    _targets.clear();
}
    
QString Assign::type() const
{
    return "Assign";
}
    

ExprTypeList Assign::targets()
{
    return _targets;
}

void Assign::setTargets(const ExprTypeList& targets)
{
    _targets = targets;
}

exprTypePtr Assign::value()
{
    return _value;
}

void Assign::setValue(const exprTypePtr& value)
{
    _value = value;
}

    
QString Assign::toString() const
{
    return QString("Assign[targets=%1, value=%2]").
                arg(_targets.toString()).
                arg(_value ? _value->toString():"");
}
    
void Assign::accept(IVisitor* visitor, const SimpleNodePtr& node)
{
    visitor->visitAssign(node.dynamicCast<Assign>());
}
    
void Assign::traverse(IVisitor* visitor)
{
    _targets.traverse(visitor);
    if (_value != NULL)
        _value->accept(visitor, _value);
}